package com.ktjy.service;

import com.ktjy.mapper.SysUserMapper;
import com.ktjy.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SysUserServiceImp implements SysUserService {

    @Autowired
    SysUserMapper sysUserMapper;

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }

    @Override
    public List<SysUser> getSysUserListBiz(SysUser sysUser) {
        return sysUserMapper.getSysUserList(sysUser);
    }

    @Override
    public int addUser(SysUser sysUser) {
        return sysUserMapper.add(sysUser);
    }

    @Transactional
    @Override
    public int addUsers(List<SysUser> list) {
        int count = 0;
        for (SysUser sysUser : list) {
            count = count + sysUserMapper.add(sysUser);
            //模拟异常
            System.out.println(1/0);
        }
        return count;
    }
}
